/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */
package cn.webrx;

import java.util.Arrays;

/**
 * <p>Project: jse2302 - ArrSort4
 * <p>Powered by webrx On 2023-06-14 14:10:33
 * <p>Created by IntelliJ IDEA
 *
 * @author  webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class ArrSort4 {
    public static void main(String[] args) {
        Student[] sts = {
                new Student(1, "李四", 50),
                new Student(100, "张三", 90),
                new Student(20, "王五", 80),
                new Student(15, "赵六", 20),
                new Student(150, "张三丰", 60)
        };

        System.out.println(sts.length);
        System.out.println(Arrays.toString(sts));
        //Arrays.sort(sts,(a,b)->a.getScore()-b.getScore());
        //Arrays.sort(sts,(a,b)->b.getScore()-a.getScore());

        //默认按 id 升序
        //Arrays.sort(sts);

        Arrays.sort(sts,(a,b)->a.getName().compareTo(b.getName()));

        System.out.println(Arrays.toString(sts));

    }
}
